<template>
  <div class="tab-bar">
    <div class="item" @click="changeTab(0)">
      <router-link to="/index" tag="span" :class="tabIndex == 0 ? 'active' : ''">首页</router-link>
    </div>
    <div class="item" @click="changeTab(1)">
      <router-link to="/friend" tag="span" :class="tabIndex == 1 ? 'active' : ''">朋友</router-link>
    </div>
    <div class="item" @click="changeTab(2)">
      <router-link to="/index" tag="span" :class="tabIndex == 2 ? 'active' : ''">
        <img src="../../static/img/+.jpg" alt=""/>
      </router-link>
    </div>
    <div class="item" @click="changeTab(3)">
      <router-link to="/index" tag="span" :class="tabIndex == 3 ? 'active' : ''">消息</router-link>
    </div>
    <div class="item" @click="changeTab(4)">
      <router-link to="/login" tag="span" :class="tabIndex == 4 ? 'active' : ''">我</router-link>
    </div>
  </div>
</template>

<script>
export default {
  name: "TabBar",
  data() {
    return {
      tabIndex: 0,
    };
  },
  methods: {
    changeTab(index) {
      this.tabIndex = index;
    },
  },
};
</script>

<style scoped>
.tab-bar {
  z-index: 9999;
  height: 50px;
  line-height: 50px;
  background-color: #000;
  width: 100%;
  position: fixed;
  bottom: 0;
  left: 0;
  float: left;
  display: flex;
  justify-items: center;
  color: #ccc;
}
.tab-bar .item {
  font-size: 16px;
  flex: 1;
  text-align: center;
}
.tab-bar .item img {
  width: 50px;
  height: 30px;
  margin-top: 10px;
}
.tab-bar .item .active {
  color: #fff;
}
</style>
